﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Furion.CMS.Database.Migrations.Migrations
{
    public partial class alpha_0010 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_Blacklist",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    HostAddress = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_Blacklist", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_Crontabs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    InstancePath = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CronExpression = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Enable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_Crontabs", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_DataDictionaryCategorys",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SortNumber = table.Column<int>(type: "int", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_DataDictionaryCategorys", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_Organizations",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Enable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    OrderId = table.Column<int>(type: "int", nullable: false),
                    ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    Path = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_Organizations", x => x.Id);
                    table.ForeignKey(
                        name: "FK_App_Organizations_App_Organizations_ParentId",
                        column: x => x.ParentId,
                        principalTable: "App_Organizations",
                        principalColumn: "Id");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_Permissions",
                columns: table => new
                {
                    Code = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ParentPaths = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Type = table.Column<int>(type: "int", nullable: false),
                    ParentCode = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DependentResources = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_Permissions", x => x.Code);
                    table.ForeignKey(
                        name: "FK_App_Permissions_App_Permissions_ParentCode",
                        column: x => x.ParentCode,
                        principalTable: "App_Permissions",
                        principalColumn: "Code");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_Roles",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Code = table.Column<string>(type: "varchar(36)", maxLength: 36, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PolicyName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    HasSeed = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    IsDefault = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_Roles", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_SiteSettings",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Title = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Logo = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    HostUrl = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Keywords = table.Column<string>(type: "varchar(800)", maxLength: 800, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "varchar(800)", maxLength: 800, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Copyright = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsSafeLock = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    SafeLockDuration = table.Column<int>(type: "int", nullable: false),
                    SafeVerifyMaxFialNumber = table.Column<int>(type: "int", nullable: false),
                    IsLoginCaptcha = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    IsTwoFactorVerify = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    IsPhoneNumberLogin = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CaptchaDuration = table.Column<int>(type: "int", nullable: false),
                    ObjectStorageMode = table.Column<int>(type: "int", nullable: false),
                    ObjectStorageParam_Url = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ObjectStorageParam_KeyId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ObjectStorageParam_KeySecret = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SmsServerProvider = table.Column<int>(type: "int", nullable: false),
                    SmsAccessParam_KeyId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SmsAccessParam_KeySecret = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SmsAccessParam_DefaultSignName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_SiteSettings", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_Users",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    NickName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Gender = table.Column<int>(type: "int", nullable: false),
                    Avatar = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Enable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Email = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EmailConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    PhoneNumber = table.Column<string>(type: "varchar(14)", maxLength: 14, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PhoneNumberConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    HasSeed = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_Users", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_Whitelist",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    HostAddress = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RefererUrl = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_Whitelist", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_CrontabExecuteRecords",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    TaskId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Result = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ExecuteStatus = table.Column<int>(type: "int", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_CrontabExecuteRecords", x => x.Id);
                    table.ForeignKey(
                        name: "FK_App_CrontabExecuteRecords_App_Crontabs_TaskId",
                        column: x => x.TaskId,
                        principalTable: "App_Crontabs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_DataDictionarys",
                columns: table => new
                {
                    DataKey = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DataValue = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CategoryId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    SortNumber = table.Column<int>(type: "int", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_DataDictionarys", x => x.DataKey);
                    table.ForeignKey(
                        name: "FK_App_DataDictionarys_App_DataDictionaryCategorys_CategoryId",
                        column: x => x.CategoryId,
                        principalTable: "App_DataDictionaryCategorys",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_OrganizationRoles",
                columns: table => new
                {
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    RoleId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_OrganizationRoles", x => new { x.OrganizationId, x.RoleId });
                    table.ForeignKey(
                        name: "FK_App_OrganizationRoles_App_Organizations_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "App_Organizations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_App_OrganizationRoles_App_Roles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "App_Roles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_RolePermissions",
                columns: table => new
                {
                    RoleId = table.Column<int>(type: "int", nullable: false),
                    PermissionCode = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_RolePermissions", x => new { x.PermissionCode, x.RoleId });
                    table.ForeignKey(
                        name: "FK_App_RolePermissions_App_Permissions_PermissionCode",
                        column: x => x.PermissionCode,
                        principalTable: "App_Permissions",
                        principalColumn: "Code",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_App_RolePermissions_App_Roles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "App_Roles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_AuditLogs",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    AppName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Table = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Operate = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RowKey = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RowContent = table.Column<string>(type: "longtext", maxLength: 2147483647, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UserId = table.Column<int>(type: "int", nullable: false),
                    IPAddress = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_AuditLogs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_App_AuditLogs_App_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "App_Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_OrganizationUsers",
                columns: table => new
                {
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    UserId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_OrganizationUsers", x => new { x.OrganizationId, x.UserId });
                    table.ForeignKey(
                        name: "FK_App_OrganizationUsers_App_Organizations_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "App_Organizations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_App_OrganizationUsers_App_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "App_Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_RoleAuthorizeds",
                columns: table => new
                {
                    RoleId = table.Column<int>(type: "int", nullable: false),
                    UserId = table.Column<int>(type: "int", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_RoleAuthorizeds", x => new { x.RoleId, x.UserId });
                    table.ForeignKey(
                        name: "FK_App_RoleAuthorizeds_App_Roles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "App_Roles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_App_RoleAuthorizeds_App_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "App_Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_UserPassports",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    UserId = table.Column<int>(type: "int", nullable: false),
                    Account = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Password = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ExtendedValues = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Type = table.Column<int>(type: "int", nullable: false),
                    RegionRestrict = table.Column<int>(type: "int", nullable: false),
                    HasSeed = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Enable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_UserPassports", x => x.Id);
                    table.ForeignKey(
                        name: "FK_App_UserPassports_App_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "App_Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_UserPermissions",
                columns: table => new
                {
                    UserId = table.Column<int>(type: "int", nullable: false),
                    PermissionCode = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_UserPermissions", x => new { x.PermissionCode, x.UserId });
                    table.ForeignKey(
                        name: "FK_App_UserPermissions_App_Permissions_PermissionCode",
                        column: x => x.PermissionCode,
                        principalTable: "App_Permissions",
                        principalColumn: "Code",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_App_UserPermissions_App_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "App_Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_UserLoginRecords",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Account = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Method = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Host = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RefererUrl = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PostData = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UserAgent = table.Column<string>(type: "varchar(800)", maxLength: 800, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsSuccess = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    ErrorMessage = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    InnerException_TrackId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    InnerException_Message = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PassportId = table.Column<int>(type: "int", nullable: true),
                    LoginTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_UserLoginRecords", x => x.Id);
                    table.ForeignKey(
                        name: "FK_App_UserLoginRecords_App_UserPassports_PassportId",
                        column: x => x.PassportId,
                        principalTable: "App_UserPassports",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.SetNull);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "App_UserPassportRestricts",
                columns: table => new
                {
                    PassportId = table.Column<int>(type: "int", nullable: false),
                    WhitelistId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_App_UserPassportRestricts", x => new { x.PassportId, x.WhitelistId });
                    table.ForeignKey(
                        name: "FK_App_UserPassportRestricts_App_UserPassports_PassportId",
                        column: x => x.PassportId,
                        principalTable: "App_UserPassports",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_App_UserPassportRestricts_App_Whitelist_WhitelistId",
                        column: x => x.WhitelistId,
                        principalTable: "App_Whitelist",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.InsertData(
                table: "App_Roles",
                columns: new[] { "Id", "Code", "CreatedTime", "Description", "HasSeed", "IsDefault", "Name", "PolicyName", "UpdatedTime" },
                values: new object[] { 1, "08da85e1-0819-4771-8490-7e78103b39f7", new DateTimeOffset(new DateTime(2022, 8, 24, 14, 57, 57, 636, DateTimeKind.Unspecified).AddTicks(8917), new TimeSpan(0, 0, 0, 0, 0)), "超级管理员，拥有全部权限的系统角色不可删除", true, false, "超级管理员", "SuperAdmin", null });

            migrationBuilder.InsertData(
                table: "App_SiteSettings",
                columns: new[] { "Id", "CaptchaDuration", "Copyright", "CreatedTime", "Description", "HostUrl", "IsLoginCaptcha", "IsPhoneNumberLogin", "IsSafeLock", "IsTwoFactorVerify", "Keywords", "Logo", "Name", "ObjectStorageMode", "SafeLockDuration", "SafeVerifyMaxFialNumber", "SmsServerProvider", "Title", "UpdatedTime" },
                values: new object[] { 1, 180, "Copyright © 2021-2022 Furion CMS", new DateTimeOffset(new DateTime(2022, 8, 24, 14, 57, 57, 643, DateTimeKind.Unspecified).AddTicks(1023), new TimeSpan(0, 0, 0, 0, 0)), null, null, false, true, true, false, null, null, "Furion CMS", 0, 300, 5, 0, "Furion CMS Pro", null });

            migrationBuilder.InsertData(
                table: "App_Users",
                columns: new[] { "Id", "Avatar", "CreatedTime", "Email", "EmailConfirmed", "Enable", "Gender", "HasSeed", "NickName", "PhoneNumber", "PhoneNumberConfirmed", "UpdatedTime" },
                values: new object[] { 1, "https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png", new DateTimeOffset(new DateTime(2022, 8, 24, 14, 57, 57, 648, DateTimeKind.Unspecified).AddTicks(6372), new TimeSpan(0, 0, 0, 0, 0)), "409408401@qq.com", true, true, 1, true, "超级管理员", "18328408303", true, null });

            migrationBuilder.InsertData(
                table: "App_RoleAuthorizeds",
                columns: new[] { "RoleId", "UserId", "CreatedTime" },
                values: new object[] { 1, 1, new DateTimeOffset(new DateTime(2022, 8, 24, 14, 57, 57, 635, DateTimeKind.Unspecified).AddTicks(5757), new TimeSpan(0, 0, 0, 0, 0)) });

            migrationBuilder.InsertData(
                table: "App_UserPassports",
                columns: new[] { "Id", "Account", "CreatedTime", "Enable", "ExtendedValues", "HasSeed", "Password", "RegionRestrict", "Type", "UpdatedTime", "UserId" },
                values: new object[] { 1, "admin", new DateTimeOffset(new DateTime(2022, 8, 24, 14, 57, 57, 650, DateTimeKind.Unspecified).AddTicks(4384), new TimeSpan(0, 0, 0, 0, 0)), true, "{}", true, "21232f297a57a5a743894a0e4a801fc3", 0, 0, null, 1 });

            migrationBuilder.CreateIndex(
                name: "IX_App_AuditLogs_Id_UserId_CreatedTime",
                table: "App_AuditLogs",
                columns: new[] { "Id", "UserId", "CreatedTime" });

            migrationBuilder.CreateIndex(
                name: "IX_App_AuditLogs_UserId",
                table: "App_AuditLogs",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_App_Blacklist_HostAddress",
                table: "App_Blacklist",
                column: "HostAddress");

            migrationBuilder.CreateIndex(
                name: "IX_App_CrontabExecuteRecords_TaskId",
                table: "App_CrontabExecuteRecords",
                column: "TaskId");

            migrationBuilder.CreateIndex(
                name: "IX_App_DataDictionarys_CategoryId",
                table: "App_DataDictionarys",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_App_DataDictionarys_DataKey",
                table: "App_DataDictionarys",
                column: "DataKey");

            migrationBuilder.CreateIndex(
                name: "IX_App_OrganizationRoles_OrganizationId_RoleId",
                table: "App_OrganizationRoles",
                columns: new[] { "OrganizationId", "RoleId" });

            migrationBuilder.CreateIndex(
                name: "IX_App_OrganizationRoles_RoleId",
                table: "App_OrganizationRoles",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_App_Organizations_ParentId",
                table: "App_Organizations",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_App_OrganizationUsers_OrganizationId_UserId",
                table: "App_OrganizationUsers",
                columns: new[] { "OrganizationId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_App_OrganizationUsers_UserId",
                table: "App_OrganizationUsers",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_App_Permissions_Code",
                table: "App_Permissions",
                column: "Code");

            migrationBuilder.CreateIndex(
                name: "IX_App_Permissions_ParentCode",
                table: "App_Permissions",
                column: "ParentCode");

            migrationBuilder.CreateIndex(
                name: "IX_App_RoleAuthorizeds_RoleId_UserId",
                table: "App_RoleAuthorizeds",
                columns: new[] { "RoleId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_App_RoleAuthorizeds_UserId",
                table: "App_RoleAuthorizeds",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_App_RolePermissions_RoleId_PermissionCode",
                table: "App_RolePermissions",
                columns: new[] { "RoleId", "PermissionCode" });

            migrationBuilder.CreateIndex(
                name: "IX_App_UserLoginRecords_LoginTime_Host_Account",
                table: "App_UserLoginRecords",
                columns: new[] { "LoginTime", "Host", "Account" });

            migrationBuilder.CreateIndex(
                name: "IX_App_UserLoginRecords_PassportId",
                table: "App_UserLoginRecords",
                column: "PassportId");

            migrationBuilder.CreateIndex(
                name: "IX_App_UserPassportRestricts_PassportId_WhitelistId",
                table: "App_UserPassportRestricts",
                columns: new[] { "PassportId", "WhitelistId" });

            migrationBuilder.CreateIndex(
                name: "IX_App_UserPassportRestricts_WhitelistId",
                table: "App_UserPassportRestricts",
                column: "WhitelistId");

            migrationBuilder.CreateIndex(
                name: "IX_App_UserPassports_UserId_Account_Type",
                table: "App_UserPassports",
                columns: new[] { "UserId", "Account", "Type" });

            migrationBuilder.CreateIndex(
                name: "IX_App_UserPermissions_UserId_PermissionCode",
                table: "App_UserPermissions",
                columns: new[] { "UserId", "PermissionCode" });

            migrationBuilder.CreateIndex(
                name: "IX_App_Whitelist_HostAddress_RefererUrl",
                table: "App_Whitelist",
                columns: new[] { "HostAddress", "RefererUrl" });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "App_AuditLogs");

            migrationBuilder.DropTable(
                name: "App_Blacklist");

            migrationBuilder.DropTable(
                name: "App_CrontabExecuteRecords");

            migrationBuilder.DropTable(
                name: "App_DataDictionarys");

            migrationBuilder.DropTable(
                name: "App_OrganizationRoles");

            migrationBuilder.DropTable(
                name: "App_OrganizationUsers");

            migrationBuilder.DropTable(
                name: "App_RoleAuthorizeds");

            migrationBuilder.DropTable(
                name: "App_RolePermissions");

            migrationBuilder.DropTable(
                name: "App_SiteSettings");

            migrationBuilder.DropTable(
                name: "App_UserLoginRecords");

            migrationBuilder.DropTable(
                name: "App_UserPassportRestricts");

            migrationBuilder.DropTable(
                name: "App_UserPermissions");

            migrationBuilder.DropTable(
                name: "App_Crontabs");

            migrationBuilder.DropTable(
                name: "App_DataDictionaryCategorys");

            migrationBuilder.DropTable(
                name: "App_Organizations");

            migrationBuilder.DropTable(
                name: "App_Roles");

            migrationBuilder.DropTable(
                name: "App_UserPassports");

            migrationBuilder.DropTable(
                name: "App_Whitelist");

            migrationBuilder.DropTable(
                name: "App_Permissions");

            migrationBuilder.DropTable(
                name: "App_Users");
        }
    }
}
